home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Newton Sample Code 1.2 / User Interface Guidelines / infoButton-1 / infoButton.text < prev    next >
Encoding:
Text File  |  1994-07-07  |  5.8 KB  |  251 lines  |  [TEXT/MPS ]

  1. // Copyright ©1994 Apple Computer, Inc., All Rights Reserved.
  2.  
  3. // constants for the application
  4.  
  5. constant kAppSymbol := '|InfoButton:PIEDTS|;
  6.  
  7. constant kMaxAppWidth := 240 ;
  8. constant kMaxAppHeight := 336 ;
  9.  
  10. // other constants
  11.  
  12. constant kAppSplashSymbol := '|Splash:InfoButton:PIEDTS| ;
  13.  
  14. // constants for the InfoButton items:
  15. constant kAboutItem := 0 ;
  16. constant kHelpItem := 1 ;
  17. constant kPrefsItem := 2 ;
  18. constant kThisWayItem := 4 ;
  19. constant kThatWayItem := 5 ;
  20. constant kTheOtherWayItem := 6 ;
  21.  
  22. // get the sounds...
  23.  
  24. r := OpenResFileX(HOME&"infoButton.rsrc") ;
  25.  
  26. DefConst('kEeahSound, GetSound("eeah")) ;
  27.  
  28. CloseResFileX(r) ;
  29. // ---- End Project Data ----
  30.  
  31.  
  32. // ---- File infoButton.t ----
  33.  
  34. // Before Script for "myBase"
  35. // Copyright ©1994 Apple Computer, Inc., All Rights Reserved.
  36.  
  37. myBase :=
  38.    {viewFlags: 4,
  39.     viewFormat: nil,
  40.     viewBounds: {left: 0, top: 0, right: 240, bottom: 328},
  41.     declareSelf: 'base,
  42.     viewSetupFormScript:
  43.       func()
  44.       begin
  45.           local l := GetAppParams();
  46.           viewBounds := RelBounds(l.AppAreaLeft, l.appAreaTop,
  47.               MIN(kMaxAppWidth, l.appAreaWidth),
  48.               MIN(kMaxAppHeight, l.appAreaHeight)) ;
  49.           :MarkAppInfoItem(kThisWayItem);
  50.       end,
  51.     AppInfoItems: nil,
  52.     InfoItemSelected:
  53.       func(item)
  54.       begin
  55.           if item = kAboutItem then
  56.               AboutView:Open();
  57.           else
  58.           if item = kHelpItem then
  59.               HelpView:Open();
  60.           else    
  61.           if item = kPrefsItem then
  62.               PrefsView:Open();
  63.           else begin
  64.               :MarkAppInfoItem(item) ;
  65.           end;
  66.               
  67.               
  68.       end,
  69.     DefaultAppInfoItems:
  70.       ["About", "Help", "Prefs", 'pickSeparator, "This Way", "That Way", "The Other Way"]
  71.     ,
  72.     MarkAppInfoItem:
  73.       func(item)
  74.       begin
  75.           AppInfoItems := DeepClone(DefaultAppInfoItems) ;
  76.           AppInfoItems[item] := {item: AppInfoItems[item], mark: kCheckMarkChar} ;
  77.           if item >= kThisWayItem then
  78.           begin
  79.               globalSortType := item ;
  80.               theTitle.title :=  titleBase & "- Sort " & DefaultAppInfoItems[globalSortType] ;
  81.               // a hack to get the title view to update itself
  82.               if theTitle.viewCObject then
  83.                   theTitle:SyncView();
  84.           end;
  85.       end,
  86.     titleBase: "Info Button",
  87.     globalSortType: 4,
  88.     viewclass: 74,
  89.     debug: "myBase"
  90.    };
  91.  
  92. _view000 := /* child of myBase */
  93.    {text: "This Space Intentionally Left Blank (well, apart from this text)",
  94.     viewBounds: {left: 0, top: 20, right: 0, bottom: -20},
  95.     viewJustify: 246,
  96.     viewFont: {family: 'NewYork, face: kFaceNormal, size: 12},
  97.     _proto: protoStaticText
  98.    };
  99.  
  100.  
  101.  
  102. _view001 := /* child of myBase */ {_proto: protoStatus};
  103.  
  104.  
  105. // ---- File protoInfoButton ----
  106.  
  107. // Before Script for "info"
  108. // Copyright ©1994 Apple Computer, Inc., All Rights Reserved.
  109.  
  110. info :=
  111.    {viewBounds: {left: 17, top: 0, right: 30, bottom: 12},
  112.     viewFormat: 67109457,
  113.     pickCancelledScript:
  114.       func()
  115.       begin
  116.           :Hilite(nil);
  117.       end,
  118.     icon: GetPictAsBits("info icon", nil),
  119.     viewClickScript:
  120.       func(unit)
  121.       begin
  122.           if :TrackHilite(unit) then
  123.           begin
  124.               local l := :LocalBox();
  125.       
  126.               DoPopUp(AppInfoItems, l.right+3, l.top, self);
  127.           end;
  128.       end,
  129.     viewFlags: 513,
  130.     viewclass: 76,
  131.     debug: "info"
  132.    };
  133.  
  134. // After Script for "info"
  135. thisView := info;
  136. // set the bounds of the button so that it is to the right
  137. // of the clock and the correct height for the status bar
  138.  
  139. // NOTE: this is the first button, so argument to the
  140. // ButtonBounds function MUST be negative
  141. thisView.viewBounds := ButtonBounds(-(thisView.viewBounds.right - thisView.viewBounds.left));
  142.  
  143.  
  144. // ---- Back in File infoButton.t ----
  145. _view002 := /* child of _view001 */
  146.    {
  147.     pickActionScript:
  148.       func(index)
  149.       begin
  150.           // MUST do this
  151.           :Hilite(nil);
  152.       
  153.           :InfoItemSelected(index) ;
  154.       end,
  155.     _proto: info
  156.    };
  157.  
  158.  
  159.  
  160.  
  161.  
  162. theTitle := /* child of myBase */
  163.    {viewBounds: {left: -12, top: 8, right: 92, bottom: 24},
  164.     _proto: protoTitle,
  165.     debug: "theTitle"
  166.    };
  167. // View theTitle is declared to myBase
  168.  
  169.  
  170.  
  171. HelpView := /* child of myBase */
  172.    {viewBounds: {left: 0, top: 0, right: 200, bottom: 100},
  173.     viewJustify: 80,
  174.     viewFlags: 0,
  175.     showSound: kEeahSound,
  176.     _proto: protoFloatNGo,
  177.     debug: "HelpView"
  178.    };
  179. // View HelpView is declared to myBase
  180.  
  181. _view003 := /* child of HelpView */
  182.    {
  183.     text:
  184.       "Hacker, help thyself.\n\nBut seriously, see the 'Beyond Help' sample code (version 3 or better) to see how to do help books."
  185.     ,
  186.     viewBounds: {top: 0, left: 0, right: 0, bottom: -10},
  187.     viewJustify: 246,
  188.     _proto: protoStaticText
  189.    };
  190.  
  191.  
  192.  
  193.  
  194.  
  195. PrefsView := /* child of myBase */
  196.    {viewBounds: {left: 0, top: 0, right: 200, bottom: 100},
  197.     viewJustify: 80,
  198.     viewFlags: 0,
  199.     showSound: kEeahSound,
  200.     _proto: protoFloatNGo,
  201.     debug: "PrefsView"
  202.    };
  203. // View PrefsView is declared to myBase
  204.  
  205. _view004 := /* child of PrefsView */
  206.    {
  207.     text:
  208.       "Hacker, help thyself.\n\nBut seriously, see the\n'Preefer Madness'\nsample code (version 4 or better) to see how to do Preferences."
  209.     ,
  210.     viewBounds: {top: 10, left: 0, right: 0, bottom: -10},
  211.     viewJustify: 246,
  212.     viewFlags: 2051,
  213.     _proto: protoStaticText
  214.    };
  215.  
  216.  
  217.  
  218.  
  219.  
  220. AboutView := /* child of myBase */
  221.    {viewBounds: {left: 0, top: 0, right: 200, bottom: 100},
  222.     viewJustify: 80,
  223.     viewFlags: 0,
  224.     showSound: kEeahSound,
  225.     _proto: protoFloatNGo,
  226.     debug: "AboutView"
  227.    };
  228. // View AboutView is declared to myBase
  229.  
  230. _view005 := /* child of AboutView */
  231.    {
  232.     text:
  233.       "Hacker, help thyself.\n\nBut seriously, see the 'Splash Screen' sample code (version 1 or better) to see how to do an About splash screen."
  234.     ,
  235.     viewBounds: {top: 10, left: 0, right: 0, bottom: -10},
  236.     viewJustify: 246,
  237.     viewFlags: 2051,
  238.     _proto: protoStaticText
  239.    };
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249. // ---- Beginning of section for non used Layout files ----
  250.  
  251. // End of output